#ifndef CSERIALPORT_H
#define CSERIALPORT_H

#include <QObject>
#include <QSerialPort>
#include <QVector>

class CSerialPort : public QObject
{
    Q_OBJECT
public:
    explicit CSerialPort(QObject *parent = nullptr);
    //获取所有串口
    QVector<QString> getPortNamelist();
    //打开串口
    void openPort(QString port);
    //判断串口号是否打开
    bool portIsOpen();
    //关闭串口
    bool closePort();
    //发送消息
    qint64 sendMsg(QString msg);
    //获取当前串口
    QString getCurrentPort();
signals:
    void getInfo(QByteArray info);
public slots:
    //读取发送的消息
    void receiveInfo();
private:
    //串口
    QSerialPort * m_serialPort{nullptr};
    QString currentPort;
};

#endif // CSERIALPORT_H
